# Test yolov11
import os
import argparse
from typing import Dict
from ultralytics import YOLO

class Yolov11App(object):
    def __init__(self):
        self.name = 'apps.fmcw.yolov11_app.Yolov11App'

def main(params:Dict = None) -> None:
    print(f'Yolov11应用研究 v0.0.1')
    # anns/yolov11/ultralytics/utils/callbacks/wb.py Ln140 直接退出该函数执行
    os.environ['WANDB_DISABLED'] = 'true'
    os.environ['WANDB_MODE'] = 'disabled'
    # 加载模型
    model = YOLO("./anns/yolov11/ultralytics/cfg/models/v8/yolov8n.yaml")  # 从头开始构建新模型
    model = model.to('cuda:1')
    # 使用模型
    model.train(data="./anns/yolov11/ultralytics/cfg/datasets/coco128.yaml", epochs=3)  # 训练模型

def parse_args() -> argparse.Namespace:
    parser = argparse.ArgumentParser()
    parser.add_argument(
        '--run_mode', action='store',
        type=int, default=1, dest='run_mode',
        help='run mode'
    )
    return parser.parse_args()

if '__main__' == __name__:
    args = parse_args()
    params = vars(args)
    main(params=params)